﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SkyDriveSimpleDumpUrls
{
	class Program
	{
		static void Main(string[] args)
		{
			if (args.Length != 2)
			{
				Console.Out.WriteLine("Please run command with your Windows Live ID user name and password!");
				Console.Out.WriteLine("Syntax:");
				Console.Out.WriteLine("   dumpurls.exe <username> <password>");
				Console.Out.WriteLine();
				Console.Out.WriteLine("This simple utility is provided by Mike Plate at http://www.mikeplate.com");
				Console.Out.WriteLine("Source code can be found at http://skydrivesimpleviewer.codeplex.com");
				return;
			}

			try
			{
				SkyDriveConnection conn = new SkyDriveConnection(args[0], args[1]);
				SkyDriveFolder[] folders = conn.GetDavFolders();
				foreach (SkyDriveFolder folder in folders)
				{
					Console.Out.WriteLine(folder.WebDAVUrl);
				}
			}
			catch (PassportException err)
			{
				if (err.Why == PassportException.Reason.Authentication)
					Console.Out.WriteLine("Error: Wrong user name or password!");
				else
					Console.Out.WriteLine("Error: " + err.Message);
			}
			catch (Exception err)
			{
				Console.Out.WriteLine("Error: " + err.Message);
			}
		}
	}
}
